//
//  CNShopCarMarkerView.m
//  BeeQuick_19
//
//  Created by w on 16/9/23.
//  Copyright © 2016年 CN Team. All rights reserved.
//

#import "CNShopCarMarkerView.h"

@implementation CNShopCarMarkerView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self =  [super initWithFrame:frame]){
        //图片
        UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_lighting"]];
        [self addSubview:imageView];
        //label
        UILabel *markTitleLabel = [[UILabel alloc]init];
        markTitleLabel.text = @"闪送超市";
        //设置label的大小
        markTitleLabel.font = [UIFont systemFontOfSize:12];
        //设置label的颜色
        markTitleLabel.textColor = [UIColor lightGrayColor];
        //自动调整lable的大小
        [markTitleLabel sizeToFit];
        [self addSubview:markTitleLabel];
        //下方的label
        UILabel *markTipsLable = [[UILabel alloc]init];
        markTipsLable.text = @"   22:00前满$30免运费,22:00后满$50免运费";
        markTipsLable.font = [UIFont systemFontOfSize:10];
        markTipsLable.textColor = [UIColor lightGrayColor];
        [self addSubview:markTipsLable];
        UIImageView *redDotImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"reddot"]];
        [self addSubview:redDotImageView];
        
        //四个控件的布局
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).offset(20);
            make.top.equalTo(self).offset(5);
            make.width.mas_equalTo(20);
            make.height.mas_equalTo(20);
            
        }];
        [markTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(imageView).offset(20);
            make.centerY.equalTo(imageView);
        }];
        [redDotImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).offset(20);
            make.top.equalTo(imageView.mas_bottom).offset(20);
            make.width.mas_equalTo(4);
            make.height.mas_equalTo(4);
        }];
        
        [markTipsLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(redDotImageView.mas_trailing).offset(15);
            make.centerY.equalTo(redDotImageView);
        }];
    
    }
    return self;
}

@end
